﻿<UserControl x:Class="MockupDesigner.AppItems.Controls.MetadataControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:s="clr-namespace:MockupDesigner.Items.Metadatas"
             mc:Ignorable="d"
             MinHeight="200"
             MinWidth="180" Background="Transparent">
    <StackPanel>
        <ItemsControl ItemsSource="{Binding Metadatas}" >
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="16" />
                            <ColumnDefinition Width="12" />
                            <ColumnDefinition Width="12" />
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Button Grid.Column="0" Click="Delete_Click" DataContext="{Binding Order}">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="../../Resources/Images/Delete.png" />
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                        <Button Grid.Column="1" Click="Up_Click" DataContext="{Binding Order}">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="../../Resources/Images/Up.png" />
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                        <Button Grid.Column="2" Click="Down_Click" DataContext="{Binding Order}">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="../../Resources/Images/Down.png" />
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                        <TextBox Grid.Column="3" TextAlignment="Left" Background="LightGray" Padding="10,0,10,0" MinWidth="100" Text="{Binding Key}" LostFocus="KeyTextBox_LostFocus" />
                        <TextBox Grid.Column="4" TextAlignment="Left" MinWidth="100" Padding="10,0,10,0" Text="{Binding Value}"/>
                    </Grid>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
        <Button HorizontalAlignment="Center" Click="Add_Click" >
            <Button.Template>
                <ControlTemplate>
                    <Image Source="../../Resources/Images/Add.png" />
                </ControlTemplate>
            </Button.Template>
            <Button.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding}" Value="{x:Null}">
                            <Setter Property="Button.Visibility" Value="Hidden" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Button.Style>
        </Button>
    </StackPanel>
</UserControl>
